<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>JS</title>
	<style>
		#bg{
			width: 100%;
			height: 100%;
			background: #000;
			position:fixed;
			top:0;
			left:0;
			opacity:0.6;
			display: none;
		}

		#login{
			width: 300px;
			height: 200px;
			border: 1px solid #ccc;
			padding-left: 30px;
			position: fixed;
			top: 40%;
			left: 35%;
			display: none;
			background-color: #fff;
		}
		h1{
			text-align: center;
		}
	</style>
</head>
<body>
	<div id="bg">
		<div id="login">
			<h1>登录</h1>
			账号：<input type="text" name="login"><br><br>
			密码：<input type="text" name="pwd">
		</div>
	</div>
	<button onclick="show()" id="btn">登录</button>

	<script>
		var bg = document.getElementById('bg');
		var login = document.getElementById('login');
		var btn = document.getElementById('btn');

		function show(){
			bg.style.display = 'block';
			login.style.display = 'block';
		}

	</script>
</body>
</html>